﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ExtendedWebApplicationInfo.cs" company="Collaboris Ltd.">
//   Copyright (c) Collaboris Ltd. All rights Reserved.
// </copyright>
// <summary>
//   Defines the ExtendedWebApplicationInfo type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Collaboris.Saf.Actions.Wss.Entities
{
    using System;
    using System.Xml.Serialization;

    using Microsoft.SharePoint.Administration;

    using SharePoint.Wss.Attributes;
    using SharePoint.Wss.Entities;

    [CollaborisClass(
           Title = "Extended Web Application Info",
           ReleaseStatus = ReleaseStatus.Beta,
           DisableDocumentation = false,
           ContactAuthorEmail = "Support@Collaboris.co.uk",
           Summary = "Defines the parameters to extend an existing web application in SharePoint."
          )]
    [Serializable]
    public class ExtendedWebApplicationInfo : WSSEntityBase
    {
        private string webAppUrl;

        private string webAppName;

        private string hostHeader;

        private int? port;

        private string loadBalancedUrl;

        private string rootDirectory;

        private bool? allowAnonymous;

        private bool? useNtlm;

        private bool? useSsl;

        private SPUrlZone urlZone;

        private bool? overwrite;
        
        [CollaborisProperty(
            Title = "Web Application Url",
            Summary = "The URL of the web application to be extended. ",
            ReadMore = "For more information on how to set expressions go " +
                        "<a href='http://www.springframework.net/doc/reference/html/expressions.html'>here</a>.",
            Example = "http://localhost:4433")]
        public string WebAppUrl
        {
            get
            {
                return webAppUrl;
            }
            set
            {
                webAppUrl = value;
            }
        }

        [CollaborisProperty(
          Summary = "Specifies the web app name for the extended web application.",
          Title = "Web App name",
          Example = "SAF New Web App Extended",
          Required = true,
          InputHint = InputHint.SingleText)]
        [XmlAttribute]
        public string WebAppName
        {
            get
            {
                return this.webAppName;
            }
            set
            {
                this.webAppName = value;
            }
        }


        [CollaborisProperty(
            Summary = "Specifies a host header for the extended web application.",
            Title = "Host Header",
            Example = "",
            Required = false,
            InputHint = InputHint.SingleText)]
        [XmlAttribute]
        public string HostHeader
        {
            get
            {
                return hostHeader;
            }
            set
            {
                hostHeader = value;
            }
        }

        [CollaborisProperty(
         Summary = "Specifies the IIS port on which to create the extended web application.",
         Title = "Overwrite",
         Example = "4444",
         Required = false,
         InputHint = InputHint.NullableNumber)]
        [XmlElement(IsNullable = true)]
        public int? Port
        {
            get
            {
                return port;
            }
            set
            {
                port = value;
            }
        }

        [CollaborisProperty(
          Summary = "Specifies the load balanced URL for the extended web app.",
          Title = "Load Balanced Url",
          Example = "",
          Required = false,
          InputHint = InputHint.SingleText)]
        [XmlAttribute]
        public string LoadBalancedUrl
        {
            get
            {
                return loadBalancedUrl;
            }
            set
            {
                loadBalancedUrl = value;
            }
        }


        [CollaborisProperty(
           Summary = "Specifies the root directory for the extended web application.",
           Title = "Root Directory",
           Example = @"c:\inetpub\wwwroot\wss\virtualdirectories\4444",
           Required = false,
           InputHint = InputHint.SingleText)]
        [XmlAttribute]
        public string RootDirectory
        {
            get
            {
                return this.rootDirectory;
            }
            set
            {
                this.rootDirectory = value;
            }
        }

        [CollaborisProperty(
          Summary = "Specifies whether to allow anonymous access to the web application.",
          Title = "Allow anonymous",
          Example = "true",
          Required = false,
          InputHint = InputHint.Boolean)]
        [XmlElement(IsNullable = true)]
        public bool? AllowAnonymous
        {
            get
            {
                return allowAnonymous;
            }
            set
            {
                allowAnonymous = value;
            }
        }

        [CollaborisProperty(
                   Summary = "Specifies whether to user NTLM authentication for the web application.",
                   Title = "User NTLM",
                   Example = "",
                   Required = false,
                   InputHint = InputHint.Boolean)]
        [XmlElement(IsNullable = true)]
        public bool? UseNTLM
        {
            get
            {
                return useNtlm;
            }
            set
            {
                useNtlm = value;
            }
        }

        [CollaborisProperty(
        Summary = "Specifies whether to use (secured sockets) SSL for the web application.",
        Title = "Use SSL",
        Example = "false",
        Required = false,
        InputHint = InputHint.Boolean)]
        [XmlElement(IsNullable = true)]
        public bool? UseSSL
        {
            get
            {
                return useSsl;
            }
            set
            {
                useSsl = value;
            }
        }

        [CollaborisProperty(
               Summary = "Specifies the URL zone in which to extend the web application.",
               Title = "Url Zone",
               Example = "Internet",
               Remarks = "Possible values are : Custom|Default|Extranet|Intranet|Internet",
               Required = false,
               InputHint = InputHint.Enum)]
        [XmlElement(IsNullable = true)]
        public SPUrlZone SPUrlZone
        {
            get
            {
                return urlZone;
            }
            set
            {
                urlZone = value;
            }
        }

        [CollaborisProperty(
            Summary = "Specifies whether to overwrite the web application if it already exists at the destination.",
            Title = "Overwrite",
            Example = "false",
            Required = false,
            InputHint = InputHint.NullableBoolean)]
        [XmlElement(IsNullable = true)]
        public bool? Overwrite
        {
            get
            {
                return overwrite;
            }
            set
            {
                overwrite = value;
            }
        }
    }
}
